package com.ktjy.factory;


import com.ktjy.Dao.NewsDao;
import com.ktjy.Dao.impl.NewsDaoImpl;

public class SimpleDaoFactory {
    public static NewsDao getInstance() {
        return new NewsDaoImpl();
    }

    public static NewsDao getInstance(String key) {
        switch (key) {
            case "mysql":
                return new NewsDaoMySqlImpl();
            case "oracle":
                return new NEwsDaoOracleImpl();
            case "redis":
                return new NewsDaoRedisImpl();
            default:
                throw new RuntimeException("无效的数据库类型：" + key + ",Dao获取失败");
        }
    }
}
